package com.bw.module_merchant.activity

import android.os.Bundle
import androidx.fragment.app.activityViewModels
import com.blankj.utilcode.util.ToastUtils

import com.bw.module_merchant.entity.AddEnterpriseParams
import com.bw.module_merchant.entity.AddProcessingStep
import com.bw.module_merchant.vm.EnterpriseRecordViewModel
import com.example.lib_common.view.view.BaseMvvmFragment
import com.example.module_merchant.R
import com.example.module_merchant.databinding.FragmentMerchantApplicationsBinding


import dagger.hilt.android.AndroidEntryPoint
import java.text.SimpleDateFormat

@AndroidEntryPoint
class MerchantApplicationsFragment : BaseMvvmFragment<FragmentMerchantApplicationsBinding>() {
    private val viewModel : EnterpriseRecordViewModel by activityViewModels()
    override fun getFragmentState(state: Bundle) {

    }

    override fun saveFragmentState(onState: Bundle) {

    }

    override fun getLayoutId(): Int = R.layout.fragment_merchant_applications



    override fun initView() {

        binding.submit.setOnClickListener {
            val params = AddEnterpriseParams(
                applicationArea = binding.addEnterpriseApplicationArea.text.toString().toInt(),
                applicationNumber = "RZ3789472934",
                contactMethod = 18888888888,
                contactName = "王守义",
                documents = listOf(),
                enterpriseName = binding.addEnterpriseName.text.toString(),
                enterpriseProfileId = 189,
                entryPersonnel = binding.addEnterprisePeopleCount.text.toString().toInt(),
                entryTime = SimpleDateFormat("yyyy-MM-dd").format(System.currentTimeMillis()),
                id = 0,
                processingSteps = listOf(AddProcessingStep("1","1")),
                status = "新建"
            )

            viewModel.addMerchantRecord(params)


            viewModel.mSuccessLiveData.observe(viewLifecycleOwner){
                ToastUtils.showLong("提交成功")
            }

            viewModel.mErrorLiveData.observe(viewLifecycleOwner){
                ToastUtils.showLong("")
            }
        }





    }


}